//2244.完成所有任务需要的最少轮数
//https://leetcode.cn/problems/minimum-rounds-to-complete-all-tasks/?envType=daily-question&envId=2024-05-14
class Solution {
public:
    int minimumRounds(vector<int>& tasks) {
        unordered_map<int,int> hash;
        for(int& n:tasks) ++hash[n];

        int ret = 0;
        for(auto& [k,v]:hash)
        {
            if(v <= 1) return -1;
            while(v)
            {
                ++ret;
                if(v >= 3) v-= 3;
                else if(v <= 2) v = 0;
            }
        }
        return ret;
    }
};